import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import home from '../views/Home.vue'
import weLcome from '../components/wecome.vue'
import user from '../components/user/user.vue'
import Rights from '../components/power/Rights.vue'
import Roles from '../components/power/Roles.vue'
import Cate from '../components/goods/Cate.vue'
import params from '../components/goods/Params.vue'
import goods from '../components/goods/goodlist.vue'
import Add from '../components/goods/Add.vue'
import Order from '../components/order/Order.vue'
import report from '../components/report/report.vue'
Vue.use(VueRouter)
const routes = [
    { path: '/', redirect: '/Login' },
    { path: '/Login', component: Login },
    {
        path: '/Home',
        component: home,
        redirect: '/welcome',
        chilren: [
            { path: '/welcome', component: weLcome },
            { path: '/user', component: user },
            { path: '/Rights', component: Rights },
            { path: '/Roles', component: Roles },
            { path: '/categries', component: Cate },
            { path: '/params', component: params },
            { path: 'goods', component: goods },
            { path: 'goods/add', component: Add },
            { path: './oreder', component: Order },
            { path: './report', component: report }
        ]
    }
]

const router = new VueRouter({
    routes
})

// router.beforeEach((to, from, next) => {
//     //to表示要跳转都路径
//     //form表示从哪个路径来
//     //next 表示放行
//     if (to.path == './Login') return next()
//     const token = window.sessionStorage.getItem('token')
//     if (!token) return next('/Login')
//     next()

// })
export default router